package com.yanqu.road.server.cmd.wingroom.message;

import com.yanqu.road.pb.wingroom.WingRoomProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2022/3/19 21:23
 */
@Cmd(code = CrossProtocol.C_WING_ROOM_GET_MESSAGE_BOARD, desc = "获取留言板内容")
public class CrossGetMessageBoardCmd extends CrossCommand {
    private long ownerServerId;
    private long ownerUserId;
    private boolean likeToday;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WingRoomProto.GetMessageBoardReqCrossMsg reqCrossMsg = WingRoomProto.GetMessageBoardReqCrossMsg.parseFrom(packet.getBytes());
        ownerServerId = reqCrossMsg.getOwnerServerId();
        ownerUserId = reqCrossMsg.getOwnerUserId();
        likeToday = reqCrossMsg.getLikeToday();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        WingRoomProto.GetMessageBoardCrossReqMsg.Builder crossReqMsg = WingRoomProto.GetMessageBoardCrossReqMsg.newBuilder();
        crossReqMsg.setGuestServerId(serverId);
        crossReqMsg.setGuestUserId(packet.getPlayerId());
        crossReqMsg.setLikeToday(likeToday);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_WING_ROOM_CROSS_REQ_MESSAGE_BOARD, crossReqMsg);
        MessageHelper.sendPacket(ownerServerId, ownerUserId, message);
    }

    @Override
    public void sendData() {

    }
}
